package xx.services.entity.rest;

import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Context;

import xx.entity.bas.SacrificeLink;
import xx.services.Passport;
import xx.services.entity.inter.ISacrificeInterface;
import xx.services.util.Constants;

/**
 * 祭奠类服务接口（一般在自然灾害时用）
 * 
 * @Path (Constants.RESTFUL_ROOT_PATH + "/sacrifice")
 * @author Administrator
 * 
 * 2010-12-19
 */
@Path(Constants.RESTFUL_ROOT_PATH + "/sacrifice")
public class SacrificeRest extends Passport implements ISacrificeInterface
{

    public SacrificeRest(@Context
    HttpServletRequest request)
    {
        super(request);
        // TODO Auto-generated constructor stub
    }

    /**
     * 为祭拜{sacrifice_id}的值加1。
     * 
     * @PUT
     * @Path ("/{sacrifice_id}/entity/{entity_id}")
     * @param sacrificeId-@PathParam("sacrifice_id")
     *            祭拜ID
     * @param entityId-@PathParam("entity_id")
     *            实体ID
     * @return 最新的祭拜值
     * @author dengjinye,2010-10-29
     * @throws SQLException
     */
    @PUT
    @Path("/{sacrifice_id}/entity/{entity_id}")
    public String updateSacrifice(@PathParam("sacrifice_id")
    long sacrificeId, @PathParam("entity_id")
    long entityId)
    {
        try
        {
            SacrificeLink sl = new SacrificeLink(qr, owner);
            sl.setEntityId(entityId).setSacrificeId(sacrificeId);
            sl.total(SacrificeLink.TOTAL, 1);
            return ok(true);
        }
        catch (Exception e)
        {
            return error(e);
        }
    }

}
